package com.study.security.authorization;

import com.study.security.domain.CurrentUser;
import com.study.security.utils.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service("sa")
public class AuthService {

    /**
     * 自定义权限
     *
     * @param permission
     * @return
     */
    public boolean hasPermission(String permission) {
        if(StringUtils.isEmpty(permission)){
            return true;
        }
        CurrentUser currentUser = SecurityUtils.getCurrentUser();

        return currentUser.getPermissions() != null && currentUser.getPermissions().contains(permission);
    }

    public boolean isAdmin(String permission){
        return true;
    }


}
